package com.city.service.party.impl;

import com.city.domain.party.PartyFabroad;
import com.city.repository.party.PartyFabroadRepository;
import com.city.service.party.PartyFabroadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @deprecation: 干部出国申请
 * @dmail: 398521613@qq.com
 * @author: L-H
 * @date: 2018-07-18 13:14
 */
@Service
public class PartyFabroadServiceImpl implements PartyFabroadService {

    @Autowired
    private PartyFabroadRepository partyFabroadRepository;

    @Override
    public List<PartyFabroad> findAll() {
        return partyFabroadRepository.findAll();
    }

    @Override
    public List<PartyFabroad> findByPage(Integer page, Integer limit) {
        return partyFabroadRepository.findAllByPage((page-1)*limit,limit);
    }

    @Override
    public long count() {
        return partyFabroadRepository.count();
    }

    @Override
    public PartyFabroad findById(int id) {
        return partyFabroadRepository.findOne(id);
    }

    @Override
    public void delete(int id) {
        partyFabroadRepository.delete(id);
    }

    @Override
    public List<PartyFabroad> findAllByDestinationAndPage(String destination, Integer page, Integer limit) {
        return partyFabroadRepository.findAllByDestinationAndPage(destination,(page-1)*limit,limit);
    }

    @Override
    public long countDestination(String destination) {
        return partyFabroadRepository.countDestination(destination);
    }

    @Override
    public List<PartyFabroad> findAllByNameAndPage(String name, Integer page, Integer limit) {
        return partyFabroadRepository.findAllByNameAndPage(name,(page-1)*limit,limit);
    }

    @Override
    public long countName(String name) {
        return partyFabroadRepository.countName(name);
    }

    @Override
    public List<PartyFabroad> findAllByDestinationAndNameAndPage(String destination, String name, Integer page, Integer limit) {
        return partyFabroadRepository.findAllByDestinationAndNameAndPage(destination,name,(page-1)*limit,limit);
    }

    @Override
    public long countDestinationAndName(String destination, String name) {
        return partyFabroadRepository.countDestinationAndName(destination, name);
    }
}
